{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "quantitative-division",
   "metadata": {},
   "source": [
    "# Applying Common Theme to a Plot Group\n",
    "\n",
    "You can add a **common theme** to an antire group of plots (i.e. `gggrid()`) to have \\\n",
    "each subplot in the group inherited this theme.\n",
    "\n",
    "Howether, a **theme** added to an individual subplot will override settings in the **common theme**."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "exceptional-beach",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"ITMLsZ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.1.0/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"ITMLsZ\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"ITMLsZ\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "changing-analysis",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.4.5.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.1.0."
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "solved-wilson",
   "metadata": {},
   "outputs": [],
   "source": [
    "import kotlin.random.Random\n",
    "\n",
    "// Line\n",
    "val start = -4 * Math.PI\n",
    "val stop = 4 * Math.PI\n",
    "val num = 100\n",
    "val step = ((stop - start) / (num - 1))\n",
    "val x = List(num) { start + it * step}\n",
    "val lineData = mapOf(\n",
    "    \"x\" to x,\n",
    "    \"y\" to x.map{Math.sin(it)}\n",
    ") \n",
    "\n",
    "val line = letsPlot(lineData) {x = \"x\"; y = \"y\"} + geomLine() + ggtitle(\"Line\")\n",
    "\n",
    "// Bars\n",
    "val rand = Random(37)\n",
    "val barData = mapOf(\n",
    "    \"x\" to List(100) { rand.nextInt(10)}\n",
    ")\n",
    "\n",
    "val bar = letsPlot(barData) {x = \"x\"} + geomBar() + ggtitle(\"Barchart\")\n",
    "\n",
    "// Boxplot\n",
    "val jRand = java.util.Random(37)\n",
    "val dict = listOf('a', 'b', 'c')\n",
    "val boxData = mapOf(\n",
    "    \"x\" to List(100) { dict[rand.nextInt(3)] }, \n",
    "    \"y\" to List(100) { jRand.nextGaussian() }\n",
    ")\n",
    "            \n",
    "val box = letsPlot(boxData) {x = \"x\"; y = \"y\"} + geomBoxplot() + ggtitle(\"Boxplot\")\n",
    "            \n",
    "// Pie\n",
    "val pieData = mapOf(\n",
    "  \"name\" to listOf(\"rock\", \"paper\", \"scissors\"),\n",
    "  \"slice\" to listOf(1, 3, 3)\n",
    ")\n",
    "\n",
    "val pie = letsPlot(pieData) + geomPie(\n",
    "                             stat = Stat.identity,\n",
    "                             size = 0.5, sizeUnit = \"x\") {fill = \"name\"; slice = \"slice\"}\n",
    "\n",
    "// Grid\n",
    "val grid = gggrid(\n",
    "    listOf(line, bar, box, pie),\n",
    "    ncol = 2\n",
    ") + ggsize(700, 400)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "rising-newton",
   "metadata": {},
   "source": [
    "#### 1. A Group without Custom Theme Settings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "involved-insulation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"HdXIpf\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Line\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[-12.566370614359172,-12.312504541341815,-12.058638468324459,-11.8047723953071,-11.550906322289745,-11.297040249272387,-11.04317417625503,-10.789308103237673,-10.535442030220317,-10.281575957202959,-10.027709884185603,-9.773843811168245,-9.519977738150889,-9.266111665133531,-9.012245592116173,-8.758379519098817,-8.50451344608146,-8.250647373064103,-7.996781300046746,-7.742915227029389,-7.489049154012032,-7.235183080994675,-6.981317007977318,-6.727450934959961,-6.473584861942603,-6.219718788925246,-5.965852715907889,-5.711986642890532,-5.458120569873175,-5.204254496855818,-4.9503884238384614,-4.6965223508211045,-4.4426562778037475,-4.18879020478639,-3.9349241317690336,-3.6810580587516757,-3.4271919857343196,-3.1733259127169617,-2.9194598396996057,-2.665593766682248,-2.4117276936648917,-2.157861620647534,-1.9039955476301778,-1.65012947461282,-1.3962634015954638,-1.142397328578106,-0.8885312555607499,-0.634665182543392,-0.38079910952603413,-0.12693303650867804,0.12693303650867982,0.3807991095260359,0.6346651825433938,0.8885312555607499,1.1423973285781077,1.3962634015954638,1.6501294746128217,1.9039955476301778,2.1578616206475356,2.4117276936648917,2.6655937666822496,2.9194598396996057,3.1733259127169635,3.4271919857343196,3.6810580587516775,3.9349241317690336,4.188790204786393,4.442656277803749,4.696522350821105,4.9503884238384614,5.204254496855821,5.458120569873177,5.711986642890533,5.965852715907889,6.219718788925249,6.473584861942605,6.727450934959961,6.981317007977317,7.235183080994677,7.489049154012033,7.742915227029389,7.996781300046749,8.250647373064105,8.50451344608146,8.758379519098817,9.012245592116177,9.266111665133533,9.519977738150889,9.773843811168245,10.027709884185604,10.28157595720296,10.535442030220317,10.789308103237673,11.043174176255032,11.297040249272388,11.550906322289745,11.804772395307104,12.05863846832446,12.312504541341816,12.566370614359172],\n",
       "\"y\":[4.898587196589413E-16,0.2511479871810805,0.48619673610046904,0.6900790114821128,0.8497254299495145,0.9549022414440742,0.998867339183008,0.9788024462147785,0.8959937742913359,0.7557495743542577,0.5670598638627707,0.342020143325668,0.09505604330418282,-0.15800139597335056,-0.40093053540661505,-0.6181589862206056,-0.7957618405308319,-0.9223542941045816,-0.9898214418809328,-0.9938384644612541,-0.9341478602651067,-0.8145759520503356,-0.6427876096865391,-0.4297949120891715,-0.18925124436040927,0.06342391965656541,0.3120334456984879,0.5406408174555982,0.7345917086575338,0.8814533634475823,0.9718115683235419,0.9998741276738751,0.9638421585599419,0.8660254037844379,0.7126941713788626,0.5136773915734053,0.2817325568414294,0.031727933498066525,-0.2203105327865408,-0.4582265217274113,-0.6667690005162917,-0.8325698546347718,-0.9450008187146685,-0.9968547759519424,-0.9848077530122081,-0.9096319953545181,-0.7761464642917569,-0.59290792905464,-0.3716624556603262,-0.1265924535737488,0.12659245357375057,0.37166245566032785,0.5929079290546414,0.7761464642917569,0.9096319953545188,0.9848077530122081,0.9968547759519423,0.9450008187146685,0.8325698546347708,0.6667690005162917,0.45822652172740974,0.2203105327865408,-0.0317279334980683,-0.2817325568414294,-0.5136773915734069,-0.7126941713788626,-0.8660254037844397,-0.9638421585599424,-0.9998741276738751,-0.9718115683235419,-0.8814533634475811,-0.7345917086575325,-0.5406408174555974,-0.3120334456984879,-0.06342391965656274,0.18925124436041102,0.4297949120891715,0.6427876096865385,0.8145759520503366,0.934147860265107,0.9938384644612541,0.9898214418809325,0.9223542941045809,0.7957618405308319,0.6181589862206056,0.40093053540661183,0.1580013959733488,-0.09505604330418282,-0.342020143325668,-0.5670598638627723,-0.7557495743542588,-0.8959937742913359,-0.9788024462147785,-0.9988673391830079,-0.9549022414440737,-0.8497254299495145,-0.6900790114821103,-0.4861967361004675,-0.2511479871810788,-4.898587196589413E-16]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Barchart\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"count\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"data\":{\n",
       "\"..count..\":[15.0,15.0,8.0,11.0,6.0,9.0,9.0,9.0,10.0,8.0],\n",
       "\"x\":[8.0,4.0,9.0,7.0,3.0,2.0,6.0,5.0,1.0,0.0]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Boxplot\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot\",\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"boxplot\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,2.2972205355496347],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.421204173272826],\n",
       "\"x\":[\"c\",\"b\",\"a\"],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot_outlier\",\n",
       "\"show_legend\":false,\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,1.9695418127098692,2.2972205355496347],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.30609243643343986,-0.421204173272826],\n",
       "\"x\":[\"c\",\"b\",\"b\",\"a\"],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3878584214688807,-1.3941301234610528],\n",
       "\"y\":[NaN,2.429780509168998,2.439598419520245,NaN]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"slice\":\"slice\",\n",
       "\"fill\":\"name\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":0.5,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"pie\",\n",
       "\"size_unit\":\"x\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"slice\":[1.0,3.0,3.0],\n",
       "\"name\":[\"rock\",\"paper\",\"scissors\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":400.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"HdXIpf\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grid"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "parental-offering",
   "metadata": {},
   "source": [
    "#### 2. Use Common Theme to Remove All Titles in Subplots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "amazing-frame",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"kY8pb1\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"theme\":{\n",
       "\"plot_title\":\"blank\",\n",
       "\"axis_title\":\"blank\"\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Line\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[-12.566370614359172,-12.312504541341815,-12.058638468324459,-11.8047723953071,-11.550906322289745,-11.297040249272387,-11.04317417625503,-10.789308103237673,-10.535442030220317,-10.281575957202959,-10.027709884185603,-9.773843811168245,-9.519977738150889,-9.266111665133531,-9.012245592116173,-8.758379519098817,-8.50451344608146,-8.250647373064103,-7.996781300046746,-7.742915227029389,-7.489049154012032,-7.235183080994675,-6.981317007977318,-6.727450934959961,-6.473584861942603,-6.219718788925246,-5.965852715907889,-5.711986642890532,-5.458120569873175,-5.204254496855818,-4.9503884238384614,-4.6965223508211045,-4.4426562778037475,-4.18879020478639,-3.9349241317690336,-3.6810580587516757,-3.4271919857343196,-3.1733259127169617,-2.9194598396996057,-2.665593766682248,-2.4117276936648917,-2.157861620647534,-1.9039955476301778,-1.65012947461282,-1.3962634015954638,-1.142397328578106,-0.8885312555607499,-0.634665182543392,-0.38079910952603413,-0.12693303650867804,0.12693303650867982,0.3807991095260359,0.6346651825433938,0.8885312555607499,1.1423973285781077,1.3962634015954638,1.6501294746128217,1.9039955476301778,2.1578616206475356,2.4117276936648917,2.6655937666822496,2.9194598396996057,3.1733259127169635,3.4271919857343196,3.6810580587516775,3.9349241317690336,4.188790204786393,4.442656277803749,4.696522350821105,4.9503884238384614,5.204254496855821,5.458120569873177,5.711986642890533,5.965852715907889,6.219718788925249,6.473584861942605,6.727450934959961,6.981317007977317,7.235183080994677,7.489049154012033,7.742915227029389,7.996781300046749,8.250647373064105,8.50451344608146,8.758379519098817,9.012245592116177,9.266111665133533,9.519977738150889,9.773843811168245,10.027709884185604,10.28157595720296,10.535442030220317,10.789308103237673,11.043174176255032,11.297040249272388,11.550906322289745,11.804772395307104,12.05863846832446,12.312504541341816,12.566370614359172],\n",
       "\"y\":[4.898587196589413E-16,0.2511479871810805,0.48619673610046904,0.6900790114821128,0.8497254299495145,0.9549022414440742,0.998867339183008,0.9788024462147785,0.8959937742913359,0.7557495743542577,0.5670598638627707,0.342020143325668,0.09505604330418282,-0.15800139597335056,-0.40093053540661505,-0.6181589862206056,-0.7957618405308319,-0.9223542941045816,-0.9898214418809328,-0.9938384644612541,-0.9341478602651067,-0.8145759520503356,-0.6427876096865391,-0.4297949120891715,-0.18925124436040927,0.06342391965656541,0.3120334456984879,0.5406408174555982,0.7345917086575338,0.8814533634475823,0.9718115683235419,0.9998741276738751,0.9638421585599419,0.8660254037844379,0.7126941713788626,0.5136773915734053,0.2817325568414294,0.031727933498066525,-0.2203105327865408,-0.4582265217274113,-0.6667690005162917,-0.8325698546347718,-0.9450008187146685,-0.9968547759519424,-0.9848077530122081,-0.9096319953545181,-0.7761464642917569,-0.59290792905464,-0.3716624556603262,-0.1265924535737488,0.12659245357375057,0.37166245566032785,0.5929079290546414,0.7761464642917569,0.9096319953545188,0.9848077530122081,0.9968547759519423,0.9450008187146685,0.8325698546347708,0.6667690005162917,0.45822652172740974,0.2203105327865408,-0.0317279334980683,-0.2817325568414294,-0.5136773915734069,-0.7126941713788626,-0.8660254037844397,-0.9638421585599424,-0.9998741276738751,-0.9718115683235419,-0.8814533634475811,-0.7345917086575325,-0.5406408174555974,-0.3120334456984879,-0.06342391965656274,0.18925124436041102,0.4297949120891715,0.6427876096865385,0.8145759520503366,0.934147860265107,0.9938384644612541,0.9898214418809325,0.9223542941045809,0.7957618405308319,0.6181589862206056,0.40093053540661183,0.1580013959733488,-0.09505604330418282,-0.342020143325668,-0.5670598638627723,-0.7557495743542588,-0.8959937742913359,-0.9788024462147785,-0.9988673391830079,-0.9549022414440737,-0.8497254299495145,-0.6900790114821103,-0.4861967361004675,-0.2511479871810788,-4.898587196589413E-16]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Barchart\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"count\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"data\":{\n",
       "\"..count..\":[15.0,15.0,8.0,11.0,6.0,9.0,9.0,9.0,10.0,8.0],\n",
       "\"x\":[8.0,4.0,9.0,7.0,3.0,2.0,6.0,5.0,1.0,0.0]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Boxplot\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot\",\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"boxplot\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.421204173272826],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot_outlier\",\n",
       "\"show_legend\":false,\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.30609243643343986,-0.421204173272826],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3878584214688807,-1.3941301234610528],\n",
       "\"y\":[NaN,2.429780509168998,2.439598419520245,NaN]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"slice\":\"slice\",\n",
       "\"fill\":\"name\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":0.5,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"pie\",\n",
       "\"size_unit\":\"x\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"slice\":[1.0,3.0,3.0],\n",
       "\"name\":[\"rock\",\"paper\",\"scissors\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":400.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"kY8pb1\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val noTitles = theme(axisTitle = \"blank\", plotTitle=\"blank\")\n",
    "\n",
    "grid + noTitles"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "furnished-pierce",
   "metadata": {},
   "source": [
    "#### 3. Add \"Common Flawor\" to All Subplots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "visible-gossip",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"ctK4ma\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"theme\":{\n",
       "\"plot_title\":\"blank\",\n",
       "\"axis_title\":\"blank\",\n",
       "\"flavor\":\"solarized_dark\"\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Line\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[-12.566370614359172,-12.312504541341815,-12.058638468324459,-11.8047723953071,-11.550906322289745,-11.297040249272387,-11.04317417625503,-10.789308103237673,-10.535442030220317,-10.281575957202959,-10.027709884185603,-9.773843811168245,-9.519977738150889,-9.266111665133531,-9.012245592116173,-8.758379519098817,-8.50451344608146,-8.250647373064103,-7.996781300046746,-7.742915227029389,-7.489049154012032,-7.235183080994675,-6.981317007977318,-6.727450934959961,-6.473584861942603,-6.219718788925246,-5.965852715907889,-5.711986642890532,-5.458120569873175,-5.204254496855818,-4.9503884238384614,-4.6965223508211045,-4.4426562778037475,-4.18879020478639,-3.9349241317690336,-3.6810580587516757,-3.4271919857343196,-3.1733259127169617,-2.9194598396996057,-2.665593766682248,-2.4117276936648917,-2.157861620647534,-1.9039955476301778,-1.65012947461282,-1.3962634015954638,-1.142397328578106,-0.8885312555607499,-0.634665182543392,-0.38079910952603413,-0.12693303650867804,0.12693303650867982,0.3807991095260359,0.6346651825433938,0.8885312555607499,1.1423973285781077,1.3962634015954638,1.6501294746128217,1.9039955476301778,2.1578616206475356,2.4117276936648917,2.6655937666822496,2.9194598396996057,3.1733259127169635,3.4271919857343196,3.6810580587516775,3.9349241317690336,4.188790204786393,4.442656277803749,4.696522350821105,4.9503884238384614,5.204254496855821,5.458120569873177,5.711986642890533,5.965852715907889,6.219718788925249,6.473584861942605,6.727450934959961,6.981317007977317,7.235183080994677,7.489049154012033,7.742915227029389,7.996781300046749,8.250647373064105,8.50451344608146,8.758379519098817,9.012245592116177,9.266111665133533,9.519977738150889,9.773843811168245,10.027709884185604,10.28157595720296,10.535442030220317,10.789308103237673,11.043174176255032,11.297040249272388,11.550906322289745,11.804772395307104,12.05863846832446,12.312504541341816,12.566370614359172],\n",
       "\"y\":[4.898587196589413E-16,0.2511479871810805,0.48619673610046904,0.6900790114821128,0.8497254299495145,0.9549022414440742,0.998867339183008,0.9788024462147785,0.8959937742913359,0.7557495743542577,0.5670598638627707,0.342020143325668,0.09505604330418282,-0.15800139597335056,-0.40093053540661505,-0.6181589862206056,-0.7957618405308319,-0.9223542941045816,-0.9898214418809328,-0.9938384644612541,-0.9341478602651067,-0.8145759520503356,-0.6427876096865391,-0.4297949120891715,-0.18925124436040927,0.06342391965656541,0.3120334456984879,0.5406408174555982,0.7345917086575338,0.8814533634475823,0.9718115683235419,0.9998741276738751,0.9638421585599419,0.8660254037844379,0.7126941713788626,0.5136773915734053,0.2817325568414294,0.031727933498066525,-0.2203105327865408,-0.4582265217274113,-0.6667690005162917,-0.8325698546347718,-0.9450008187146685,-0.9968547759519424,-0.9848077530122081,-0.9096319953545181,-0.7761464642917569,-0.59290792905464,-0.3716624556603262,-0.1265924535737488,0.12659245357375057,0.37166245566032785,0.5929079290546414,0.7761464642917569,0.9096319953545188,0.9848077530122081,0.9968547759519423,0.9450008187146685,0.8325698546347708,0.6667690005162917,0.45822652172740974,0.2203105327865408,-0.0317279334980683,-0.2817325568414294,-0.5136773915734069,-0.7126941713788626,-0.8660254037844397,-0.9638421585599424,-0.9998741276738751,-0.9718115683235419,-0.8814533634475811,-0.7345917086575325,-0.5406408174555974,-0.3120334456984879,-0.06342391965656274,0.18925124436041102,0.4297949120891715,0.6427876096865385,0.8145759520503366,0.934147860265107,0.9938384644612541,0.9898214418809325,0.9223542941045809,0.7957618405308319,0.6181589862206056,0.40093053540661183,0.1580013959733488,-0.09505604330418282,-0.342020143325668,-0.5670598638627723,-0.7557495743542588,-0.8959937742913359,-0.9788024462147785,-0.9988673391830079,-0.9549022414440737,-0.8497254299495145,-0.6900790114821103,-0.4861967361004675,-0.2511479871810788,-4.898587196589413E-16]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Barchart\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"count\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"data\":{\n",
       "\"..count..\":[15.0,15.0,8.0,11.0,6.0,9.0,9.0,9.0,10.0,8.0],\n",
       "\"x\":[8.0,4.0,9.0,7.0,3.0,2.0,6.0,5.0,1.0,0.0]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Boxplot\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot\",\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"boxplot\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.421204173272826],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot_outlier\",\n",
       "\"show_legend\":false,\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.30609243643343986,-0.421204173272826],\n",
       "\"y\":[NaN,2.429780509168998,2.439598419520245,NaN],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"slice\":\"slice\",\n",
       "\"fill\":\"name\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":0.5,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"pie\",\n",
       "\"size_unit\":\"x\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"slice\":[1.0,3.0,3.0],\n",
       "\"name\":[\"rock\",\"paper\",\"scissors\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":400.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"ctK4ma\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val noTitlesDark = noTitles + flavorSolarizedDark()\n",
    "\n",
    "grid + noTitlesDark"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "divine-titanium",
   "metadata": {},
   "source": [
    "#### 4. Customize the Pie Chart Theme Individually"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "medieval-caution",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"vkfkqb\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"theme\":{\n",
       "\"plot_title\":\"blank\",\n",
       "\"axis_title\":\"blank\",\n",
       "\"flavor\":\"solarized_dark\"\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Line\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[-12.566370614359172,-12.312504541341815,-12.058638468324459,-11.8047723953071,-11.550906322289745,-11.297040249272387,-11.04317417625503,-10.789308103237673,-10.535442030220317,-10.281575957202959,-10.027709884185603,-9.773843811168245,-9.519977738150889,-9.266111665133531,-9.012245592116173,-8.758379519098817,-8.50451344608146,-8.250647373064103,-7.996781300046746,-7.742915227029389,-7.489049154012032,-7.235183080994675,-6.981317007977318,-6.727450934959961,-6.473584861942603,-6.219718788925246,-5.965852715907889,-5.711986642890532,-5.458120569873175,-5.204254496855818,-4.9503884238384614,-4.6965223508211045,-4.4426562778037475,-4.18879020478639,-3.9349241317690336,-3.6810580587516757,-3.4271919857343196,-3.1733259127169617,-2.9194598396996057,-2.665593766682248,-2.4117276936648917,-2.157861620647534,-1.9039955476301778,-1.65012947461282,-1.3962634015954638,-1.142397328578106,-0.8885312555607499,-0.634665182543392,-0.38079910952603413,-0.12693303650867804,0.12693303650867982,0.3807991095260359,0.6346651825433938,0.8885312555607499,1.1423973285781077,1.3962634015954638,1.6501294746128217,1.9039955476301778,2.1578616206475356,2.4117276936648917,2.6655937666822496,2.9194598396996057,3.1733259127169635,3.4271919857343196,3.6810580587516775,3.9349241317690336,4.188790204786393,4.442656277803749,4.696522350821105,4.9503884238384614,5.204254496855821,5.458120569873177,5.711986642890533,5.965852715907889,6.219718788925249,6.473584861942605,6.727450934959961,6.981317007977317,7.235183080994677,7.489049154012033,7.742915227029389,7.996781300046749,8.250647373064105,8.50451344608146,8.758379519098817,9.012245592116177,9.266111665133533,9.519977738150889,9.773843811168245,10.027709884185604,10.28157595720296,10.535442030220317,10.789308103237673,11.043174176255032,11.297040249272388,11.550906322289745,11.804772395307104,12.05863846832446,12.312504541341816,12.566370614359172],\n",
       "\"y\":[4.898587196589413E-16,0.2511479871810805,0.48619673610046904,0.6900790114821128,0.8497254299495145,0.9549022414440742,0.998867339183008,0.9788024462147785,0.8959937742913359,0.7557495743542577,0.5670598638627707,0.342020143325668,0.09505604330418282,-0.15800139597335056,-0.40093053540661505,-0.6181589862206056,-0.7957618405308319,-0.9223542941045816,-0.9898214418809328,-0.9938384644612541,-0.9341478602651067,-0.8145759520503356,-0.6427876096865391,-0.4297949120891715,-0.18925124436040927,0.06342391965656541,0.3120334456984879,0.5406408174555982,0.7345917086575338,0.8814533634475823,0.9718115683235419,0.9998741276738751,0.9638421585599419,0.8660254037844379,0.7126941713788626,0.5136773915734053,0.2817325568414294,0.031727933498066525,-0.2203105327865408,-0.4582265217274113,-0.6667690005162917,-0.8325698546347718,-0.9450008187146685,-0.9968547759519424,-0.9848077530122081,-0.9096319953545181,-0.7761464642917569,-0.59290792905464,-0.3716624556603262,-0.1265924535737488,0.12659245357375057,0.37166245566032785,0.5929079290546414,0.7761464642917569,0.9096319953545188,0.9848077530122081,0.9968547759519423,0.9450008187146685,0.8325698546347708,0.6667690005162917,0.45822652172740974,0.2203105327865408,-0.0317279334980683,-0.2817325568414294,-0.5136773915734069,-0.7126941713788626,-0.8660254037844397,-0.9638421585599424,-0.9998741276738751,-0.9718115683235419,-0.8814533634475811,-0.7345917086575325,-0.5406408174555974,-0.3120334456984879,-0.06342391965656274,0.18925124436041102,0.4297949120891715,0.6427876096865385,0.8145759520503366,0.934147860265107,0.9938384644612541,0.9898214418809325,0.9223542941045809,0.7957618405308319,0.6181589862206056,0.40093053540661183,0.1580013959733488,-0.09505604330418282,-0.342020143325668,-0.5670598638627723,-0.7557495743542588,-0.8959937742913359,-0.9788024462147785,-0.9988673391830079,-0.9549022414440737,-0.8497254299495145,-0.6900790114821103,-0.4861967361004675,-0.2511479871810788,-4.898587196589413E-16]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Barchart\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"count\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"data\":{\n",
       "\"..count..\":[15.0,15.0,8.0,11.0,6.0,9.0,9.0,9.0,10.0,8.0],\n",
       "\"x\":[8.0,4.0,9.0,7.0,3.0,2.0,6.0,5.0,1.0,0.0]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Boxplot\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot\",\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"boxplot\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,2.2972205355496347],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.421204173272826],\n",
       "\"x\":[\"c\",\"b\",\"a\"],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot_outlier\",\n",
       "\"show_legend\":false,\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,1.9695418127098692,2.2972205355496347],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.30609243643343986,-0.421204173272826],\n",
       "\"x\":[\"c\",\"b\",\"b\",\"a\"],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3878584214688807,-1.3941301234610528],\n",
       "\"y\":[NaN,2.429780509168998,2.439598419520245,NaN]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"slice\":[1.0,3.0,3.0],\n",
       "\"name\":[\"rock\",\"paper\",\"scissors\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"slice\":\"slice\",\n",
       "\"fill\":\"name\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":0.5,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"pie\",\n",
       "\"size_unit\":\"x\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"theme\":{\n",
       "\"name\":\"classic\",\n",
       "\"axis\":{\n",
       "\"blank\":true\n",
       "},\n",
       "\"line\":{\n",
       "\"blank\":true\n",
       "},\n",
       "\"flavor\":\"solarized_dark\"\n",
       "}\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":400.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"vkfkqb\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val pieTheme = themeVoid() + flavorSolarizedDark()\n",
    "\n",
    "gggrid(listOf(line, bar, box, \n",
    "        pie + pieTheme),\n",
    "        ncol = 2\n",
    ") + ggsize(700, 400) + noTitlesDark"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "atmospheric-evolution",
   "metadata": {},
   "source": [
    "#### 5. Add Common Margins and Border"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "excess-vietnam",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"aqG6oH\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":2,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"theme\":{\n",
       "\"plot_title\":\"blank\",\n",
       "\"axis_title\":\"blank\",\n",
       "\"flavor\":\"solarized_dark\",\n",
       "\"plot_background\":{\n",
       "\"color\":\"orange\",\n",
       "\"size\":20.0,\n",
       "\"blank\":false\n",
       "},\n",
       "\"plot_margin\":{\n",
       "\"t\":40.0,\n",
       "\"r\":40.0,\n",
       "\"b\":40.0,\n",
       "\"l\":40.0\n",
       "}\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Line\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[-12.566370614359172,-12.312504541341815,-12.058638468324459,-11.8047723953071,-11.550906322289745,-11.297040249272387,-11.04317417625503,-10.789308103237673,-10.535442030220317,-10.281575957202959,-10.027709884185603,-9.773843811168245,-9.519977738150889,-9.266111665133531,-9.012245592116173,-8.758379519098817,-8.50451344608146,-8.250647373064103,-7.996781300046746,-7.742915227029389,-7.489049154012032,-7.235183080994675,-6.981317007977318,-6.727450934959961,-6.473584861942603,-6.219718788925246,-5.965852715907889,-5.711986642890532,-5.458120569873175,-5.204254496855818,-4.9503884238384614,-4.6965223508211045,-4.4426562778037475,-4.18879020478639,-3.9349241317690336,-3.6810580587516757,-3.4271919857343196,-3.1733259127169617,-2.9194598396996057,-2.665593766682248,-2.4117276936648917,-2.157861620647534,-1.9039955476301778,-1.65012947461282,-1.3962634015954638,-1.142397328578106,-0.8885312555607499,-0.634665182543392,-0.38079910952603413,-0.12693303650867804,0.12693303650867982,0.3807991095260359,0.6346651825433938,0.8885312555607499,1.1423973285781077,1.3962634015954638,1.6501294746128217,1.9039955476301778,2.1578616206475356,2.4117276936648917,2.6655937666822496,2.9194598396996057,3.1733259127169635,3.4271919857343196,3.6810580587516775,3.9349241317690336,4.188790204786393,4.442656277803749,4.696522350821105,4.9503884238384614,5.204254496855821,5.458120569873177,5.711986642890533,5.965852715907889,6.219718788925249,6.473584861942605,6.727450934959961,6.981317007977317,7.235183080994677,7.489049154012033,7.742915227029389,7.996781300046749,8.250647373064105,8.50451344608146,8.758379519098817,9.012245592116177,9.266111665133533,9.519977738150889,9.773843811168245,10.027709884185604,10.28157595720296,10.535442030220317,10.789308103237673,11.043174176255032,11.297040249272388,11.550906322289745,11.804772395307104,12.05863846832446,12.312504541341816,12.566370614359172],\n",
       "\"y\":[4.898587196589413E-16,0.2511479871810805,0.48619673610046904,0.6900790114821128,0.8497254299495145,0.9549022414440742,0.998867339183008,0.9788024462147785,0.8959937742913359,0.7557495743542577,0.5670598638627707,0.342020143325668,0.09505604330418282,-0.15800139597335056,-0.40093053540661505,-0.6181589862206056,-0.7957618405308319,-0.9223542941045816,-0.9898214418809328,-0.9938384644612541,-0.9341478602651067,-0.8145759520503356,-0.6427876096865391,-0.4297949120891715,-0.18925124436040927,0.06342391965656541,0.3120334456984879,0.5406408174555982,0.7345917086575338,0.8814533634475823,0.9718115683235419,0.9998741276738751,0.9638421585599419,0.8660254037844379,0.7126941713788626,0.5136773915734053,0.2817325568414294,0.031727933498066525,-0.2203105327865408,-0.4582265217274113,-0.6667690005162917,-0.8325698546347718,-0.9450008187146685,-0.9968547759519424,-0.9848077530122081,-0.9096319953545181,-0.7761464642917569,-0.59290792905464,-0.3716624556603262,-0.1265924535737488,0.12659245357375057,0.37166245566032785,0.5929079290546414,0.7761464642917569,0.9096319953545188,0.9848077530122081,0.9968547759519423,0.9450008187146685,0.8325698546347708,0.6667690005162917,0.45822652172740974,0.2203105327865408,-0.0317279334980683,-0.2817325568414294,-0.5136773915734069,-0.7126941713788626,-0.8660254037844397,-0.9638421585599424,-0.9998741276738751,-0.9718115683235419,-0.8814533634475811,-0.7345917086575325,-0.5406408174555974,-0.3120334456984879,-0.06342391965656274,0.18925124436041102,0.4297949120891715,0.6427876096865385,0.8145759520503366,0.934147860265107,0.9938384644612541,0.9898214418809325,0.9223542941045809,0.7957618405308319,0.6181589862206056,0.40093053540661183,0.1580013959733488,-0.09505604330418282,-0.342020143325668,-0.5670598638627723,-0.7557495743542588,-0.8959937742913359,-0.9788024462147785,-0.9988673391830079,-0.9549022414440737,-0.8497254299495145,-0.6900790114821103,-0.4861967361004675,-0.2511479871810788,-4.898587196589413E-16]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Barchart\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"count\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"data\":{\n",
       "\"..count..\":[15.0,15.0,8.0,11.0,6.0,9.0,9.0,9.0,10.0,8.0],\n",
       "\"x\":[8.0,4.0,9.0,7.0,3.0,2.0,6.0,5.0,1.0,0.0]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Boxplot\"\n",
       "},\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot\",\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"boxplot\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.421204173272826],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3941301234610528]\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"boxplot_outlier\",\n",
       "\"show_legend\":false,\n",
       "\"position\":\"dodge\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "\"..middle..\":[-0.209489786045136,0.2144892451035325,0.2144892451035325,0.22276634689927832],\n",
       "\"..upper..\":[0.40713450838998066,0.725015736164894,0.725015736164894,0.7591661462662529],\n",
       "\"..ymax..\":[1.7687943677666822,1.9695418127098692,1.9695418127098692,2.2972205355496347],\n",
       "\"x\":[\"c\",\"b\",\"b\",\"a\"],\n",
       "\"..lower..\":[-0.6739853262611326,-0.30609243643343986,-0.30609243643343986,-0.421204173272826],\n",
       "\"..ymin..\":[-2.20104878328904,-1.3878584214688807,-1.3878584214688807,-1.3941301234610528],\n",
       "\"y\":[NaN,2.429780509168998,2.439598419520245,NaN]\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"slice\":[1.0,3.0,3.0],\n",
       "\"name\":[\"rock\",\"paper\",\"scissors\"]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"slice\":\"slice\",\n",
       "\"fill\":\"name\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":0.5,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"pie\",\n",
       "\"size_unit\":\"x\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"theme\":{\n",
       "\"name\":\"classic\",\n",
       "\"axis\":{\n",
       "\"blank\":true\n",
       "},\n",
       "\"line\":{\n",
       "\"blank\":true\n",
       "},\n",
       "\"flavor\":\"solarized_dark\"\n",
       "}\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":400.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"aqG6oH\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val noTitlesDarkMargins = noTitlesDark +\n",
    "    theme(plotMargin = margin(40, 40, 40, 40), plotBackground = elementRect(color = \"orange\", size = 20))\n",
    "\n",
    "gggrid(listOf(line, bar, box, \n",
    "        pie + pieTheme),\n",
    "        ncol = 2\n",
    ") + ggsize(700, 400) + noTitlesDarkMargins"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
